package com.yyw.foodie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yyw.foodie.mapper.CarouselMapper;
import com.yyw.foodie.pojo.CarouselEntity;
import com.yyw.foodie.service.CarouselService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 轮播图  服务实现类
 * </p>
 *
 * @author yiyw
 * @since 2021-05-22
 */
@Service
public class CarouselServiceImpl extends ServiceImpl<CarouselMapper, CarouselEntity> implements CarouselService {

    /**
     * 获取轮播图数据
     * @param isShow  是否展示
     * @return
     */
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<CarouselEntity> getCarouselList(Integer isShow) {
        QueryWrapper<CarouselEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(CarouselEntity::getIsShow, isShow).orderByDesc(CarouselEntity::getSort);
        List<CarouselEntity> list = list(queryWrapper);
        return list;
    }
}
